﻿Ext.application({
    name: 'Happy.navigation.shell',
    paths: {
        'Happy.navigation.shell': 'app',
        'Happy': '../../../Happy/src'
    },
    views: ['NavigationPanel', 'WorkPanel', 'TitlePanel'],
    refs: [{
        ref: 'workPanel',
        selector: 'shell-work-panel'
    }],

    launch: function () {
        var me = this;

        Ext.create('Ext.container.Viewport', {
            layout: 'border',
            items: [
                {
                    region: 'north',
                    xtype: 'shell-title-panel',
                    split: true,
                    height: 35,
                    margins: '0 5 5 5'
                },
                {
                    region: 'west',
                    xtype: 'shell-navigation-panel',
                    collapsible: true,
                    split: true,
                    width: 250,
                    margins: '5 0 5 5'
                },
                {
                    region: 'center',
                    xtype: 'shell-work-panel',
                    margins: '5 5 5 0'
                }
            ]
        });

        me.control({
            'shell-navigation-panel': {
                itemclick: me.on_Shell_Navigation_Panel_ItemClick_Handler
            }
        });
    },

    on_Shell_Navigation_Panel_ItemClick_Handler: function (_, record) {
        var me = this;

        me.getWorkPanel().showMenuItem(record);
    }
});